home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
pxewin.zip
/
PXFIELD.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-06
|
16KB
|
534 lines
// PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
// PXFIELD.HPP //
// Contents ----------------------------------------------------------------
//
// This module contains the following classes:
//
// 1. PXField. This is the general field class for dispatching the
// field type to the correct field class.
//
// 2. PXFieldTypeBase. This is the base class for all field types.
//
// 3. PXFieldTypeChar. For character type fields.
//
// 4. PXFieldTypeLong. For long type fields.
//
// 5. PXFieldTypeShort. For short type fields.
//
// 6. PXFieldTypeDouble. For double type fields.
//
// 7. PXFieldTypeDate. For date type fields.
//
// All Puts and gets to fields start or end with character data. This
// is a basic design constrient of the PXEWIN library. Character data
// is sufficient for most browsing and editing functionality.
//
// End ---------------------------------------------------------------------
// External Reference Name for this Header ---------------------------------
#ifndef PXFIELD_HPP
#define PXFIELD_HPP
// End ---------------------------------------------------------------------
// Interface Dependencies --------------------------------------------------
#ifndef PXEOBJ_HPP
#include "pxeobj.hpp"
#endif // PXEOBJ_HPP //
// End ---------------------------------------------------------------------
// class PXField //
_CLASSDEF(PXFieldTypeBase)
class PXFieldTypeBase;
#define MAX_FLD_NAME_SIZE 26 /* This is the maximum size
of a field name */
#define MAX_FLD_TYPE_SIZE 6 /* The maximum size of a
field type */
_CLASSDEF(PXField)
class PXField:public PXEngObject
{
private:
virtual const Pchar streamableName()
const /* Defines the streamable
name for this class. */
{
return "PXField";
}
protected:
FIELDHANDLE fld; /* The field handle */
Pchar fldtype; /* Field type indentifier */
Pchar fldname; /* The name of the field */
/* Base point for field
types */
PPXFieldTypeBase my_type;
virtual Pvoid read(Ripstream); /* Read persistant object */
virtual void write(Ropstream); /* Write persistant object */
PXField(StreamableInit): /* Persistant object
constructor */
PXEngObject(streamableInit)
{
}
public:
/* Pass the Record object and
field handle to the
constuctor. */
PXField(PPXRec my_object,
FIELDHANDLE FldHandle);
PXField(PPXField my_field); /* Analogous to a copy
constructor so that
derived types can
reference back to the
parent. */
static PTStreamable build(); /* Build persistant object */
~PXField(void);
int RetCharSize(); /* Return the size of this
field in characters */
Pchar RetName() /* Return field name */
{
return fldname;
}
Pchar Get(); /* Get the field data */
virtual void PXError(int org); /* PXField error handler */
};
// Description -------------------------------------------------------------
//
// This class contains constructors, destructors and members needed to
// access a field in a Paradox table. It uses PXENGINE function calls.
// The main purpose of this class is to figure out what type of field
// object you have and provide a generic field class for all field
// types to derive themselves from. You can make an array of fields
// with a common data type.
//
// End ---------------------------------------------------------------------
typedef PXField _FAR **PPPXField; /* You'll need this for a
DLL compatible array of
fields. */
// Define inserters and extractors for persistant objects:
inline Ripstream operator >> (Ripstream is,RPXField cl)
{return is >> (RTStreamable)cl;}
inline Ripstream operator >> (Ripstream is,RPPXField cl)
{return is >> (RPvoid)cl;}
inline Ropstream operator << (Ropstream os,RPXField cl)
{return os << (RTStreamable)cl;}
inline Ropstream operator << (Ropstream os,PPXField cl)
{return os << (PTStreamable)cl;}
// class PXFieldTypeBase //
class PXFieldTypeBase:public PXField
{
private:
virtual const Pchar streamableName()
const /* Defines the streamable
name for this class. */
{
return "PXFieldTypeBase";
}
protected:
int size; /* Size of storage area */
int char_size; /* This is the maximum size
of the field after it has
been converted to
character data */
Pchar char_dat; /* Character version of data
*/
virtual Pvoid read(Ripstream); /* Read persistant object */
virtual void write(Ropstream); /* Write persistant object */
PXFieldTypeBase(StreamableInit): /* Persistant object
constructor */
PXField(streamableInit)
{
}
public:
/* Constructor references
back to PXField class */
PXFieldTypeBase(PPXField my_field):
PXField(my_field)
{
}
static PTStreamable build(); /* Build persistant object */
virtual int Get(void) /* Get the data */
{
return PXSUCCESS;
}
virtual int Put(void) /* Put the data */
{
return PXSUCCESS;
}
int RetCharSize() /* Return character size */
{
return char_size;
}
Pchar RetCharData() /* Returns character data */
{
return char_dat;
}
};
// Description -------------------------------------------------------------
//
// The PXFieldTypeBase defines the base class for getting and putting
// fields of different types to and from the database. Each of the
// data type specific functions are spec'ed out in the preceding
// classes. Members Put and Get could have been defined as pure
// virtuals since they serve only as place holders for derived types.
// The only reason for declaring them as such is for virtual error
// dispatching back to the MDI frame window. This would lead to a
// compiler error because you would be making an instance of a abstract
// class.
//
// End ---------------------------------------------------------------------
// Define inserters and extractors for persistant objects:
inline Ripstream operator >> (Ripstream is,RPXFieldTypeBase cl)
{return is >> (RTStreamable)cl;}
inline Ripstream operator >> (Ripstream is,RPPXFieldTypeBase cl)
{return is >> (RPvoid)cl;}
inline Ropstream operator << (Ropstream os,RPXFieldTypeBase cl)
{return os << (RTStreamable)cl;}
inline Ropstream operator << (Ropstream os,PPXFieldTypeBase cl)
{return os << (PTStreamable)cl;}
// class PXFieldTypeChar //
_CLASSDEF(PXFieldTypeChar)
class PXFieldTypeChar:public PXFieldTypeBase
{
private:
Pchar data; /* Data buffer */
virtual const Pchar streamableName()
const /* Defines the streamable
name for this class. */
{
return "PXFieldTypeChar";
}
protected:
virtual Pvoid read(Ripstream); /* Read persistant object */
virtual void write(Ropstream); /* Write persistant object */
PXFieldTypeChar(StreamableInit): /* Persistant object
constructor */
PXFieldTypeBase(streamableInit)
{
}
public:
/* constructor references
back to PXField parent
object. The sz parameter
is for the size of the
string. */
PXFieldTypeChar(PPXField my_field,int sz);
~PXFieldTypeChar(void);
static PTStreamable build(); /* Build persistant object */
/* Get data into buffer from
database */
int Get(void);
/* Put your character data
in the record buffer */
int Put(void);
};
// Description -------------------------------------------------------------
//
// This class spec's out getting and putting functions for character
// type data.
//
// End ---------------------------------------------------------------------
// Define inserters and extractors for persistant objects:
inline Ripstream operator >> (Ripstream is,RPXFieldTypeChar cl)
{return is >> (RTStreamable)cl;}
inline Ripstream operator >> (Ripstream is,RPPXFieldTypeChar cl)
{return is >> (RPvoid)cl;}
inline Ropstream operator << (Ropstream os,RPXFieldTypeChar cl)
{return os << (RTStreamable)cl;}
inline Ropstream operator << (Ropstream os,PPXFieldTypeChar cl)
{return os << (PTStreamable)cl;}
// class PXFieldTypeDouble //
#define DOUBLE_SIZE 21 /* Maximum number of
characters it takes to
display this field
including a decimal point,
a minus sign, and 5
commas.
*/
_CLASSDEF(PXFieldTypeDouble)
class PXFieldTypeDouble:public PXFieldTypeBase
{
private:
Pdouble data; /* Data buffer */
virtual const Pchar streamableName()
const /* Defines the streamable
name for this class. */
{
return "PXFieldTypeDouble";
}
protected:
virtual Pvoid read(Ripstream); /* Read persistant object */
virtual void write(Ropstream); /* Write persistant object */
PXFieldTypeDouble(StreamableInit): /* Persistant object
constructor */
PXFieldTypeBase(streamableInit)
{
}
public:
/* Constructor references
back to parent */
PXFieldTypeDouble(PPXField my_field);
~PXFieldTypeDouble(void);
/* Get data into buffer from
database */
static PTStreamable build(); /* Build persistant object */
int Get(void);
/* Put your data in the
record buffer */
int Put(void);
};
// Description -------------------------------------------------------------
//
// This class spec's out getting and putting functions for double type
// data.
//
// End ---------------------------------------------------------------------
// Define inserters and extractors for persistant objects:
inline Ripstream operator >> (Ripstream is,RPXFieldTypeDouble cl)
{return is >> (RTStreamable)cl;}
inline Ripstream operator >> (Ripstream is,RPPXFieldTypeDouble cl)
{return is >> (RPvoid)cl;}
inline Ropstream operator << (Ropstream os,RPXFieldTypeDouble cl)
{return os << (RTStreamable)cl;}
inline Ropstream operator << (Ropstream os,PPXFieldTypeDouble cl)
{return os << (PTStreamable)cl;}
// class PXFieldTypeLong //
#define LONGSIZE 14 /* Maximum number of
characters it would take
to display a long number
including a decimal point
(if you are using $'s),
a minus sign, and 3
commas.
*/
_CLASSDEF(PXFieldTypeLong)
class PXFieldTypeLong:public PXFieldTypeBase
{
private:
Plong data; /* Data buffer */
virtual const Pchar streamableName()
const /* Defines the streamable
name for this class. */
{
return "PXFieldTypeLong";
}
protected:
virtual Pvoid read(Ripstream); /* Read persistant object */
virtual void write(Ropstream); /* Write persistant object */
PXFieldTypeLong(StreamableInit): /* Persistant object
constructor */
PXFieldTypeBase(streamableInit)
{
}
public:
PXFieldTypeLong(PPXField my_field); /* Constructor references
back to parent. */
~PXFieldTypeLong(void);
static PTStreamable build(); /* Build persistant object */
/* Get data into buffer from
database */
int Get(void);
/* Put your data in the
record buffer */
int Put(void);
};
// Description -------------------------------------------------------------
//
// This class spec's out getting and putting functions for long type
// data.
//
// End ---------------------------------------------------------------------
// Define inserters and extractors for persistant objects:
inline Ripstream operator >> (Ripstream is,RPXFieldTypeLong cl)
{return is >> (RTStreamable)cl;}
inline Ripstream operator >> (Ripstream is,RPPXFieldTypeLong cl)
{return is >> (RPvoid)cl;}
inline Ropstream operator << (Ropstream os,RPXFieldTypeLong cl)
{return os << (RTStreamable)cl;}
inline Ropstream operator << (Ropstream os,PPXFieldTypeLong cl)
{return os << (PTStreamable)cl;}
// class PXFieldTypeShort //
#define SHORT_SIZE 8 /* Maximum number of
characters it would take
to represent a short
number including a minus
sign, a comma, and a
decimal point (if you
wish to format the data
futher). */
_CLASSDEF(PXFieldTypeShort)
class PXFieldTypeShort:public PXFieldTypeBase
{
private:
Pshort data; /* Data buffer */
virtual const Pchar streamableName()
const /* Defines the streamable
name for this class. */
{
return "PXFieldTypeShort";
}
protected:
virtual Pvoid read(Ripstream); /* Read persistant object */
virtual void write(Ropstream); /* Write persistant object */
PXFieldTypeShort(StreamableInit): /* Persistant object
constructor */
PXFieldTypeBase(streamableInit)
{
}
public:
PXFieldTypeShort(PPXField my_field); /* Constructor refences back
to parent. */
~PXFieldTypeShort(void);
static PTStreamable build(); /* Build persistant object */
/* Get data into buffer from
database */
int Get(void);
/* Put your data in the
record buffer */
int Put(void);
};
// Description -------------------------------------------------------------
//
// This class spec's out getting and putting functions for short type
// data.
//
// End ---------------------------------------------------------------------
// Define inserters and extractors for persistant objects:
inline Ripstream operator >> (Ripstream is,RPXFieldTypeShort cl)
{return is >> (RTStreamable)cl;}
inline Ripstream operator >> (Ripstream is,RPPXFieldTypeShort cl)
{return is >> (RPvoid)cl;}
inline Ropstream operator << (Ropstream os,RPXFieldTypeShort cl)
{return os << (RTStreamable)cl;}
inline Ropstream operator << (Ropstream os,PPXFieldTypeShort cl)
{return os << (PTStreamable)cl;}
// class PXFieldTypeDate //
#define DATE_SIZE 10 /* Maximum number of
characters you would need
to define a date (i.e.
12-03-1989). */
_CLASSDEF(PXFieldTypeDate)
class PXFieldTypeDate:public PXFieldTypeBase
{
private:
PDATES data; /* Data buffer */
virtual const Pchar streamableName()
const /* Defines the streamable
name for this class. */
{
return "PXFieldTypeDate";
}
protected:
virtual Pvoid read(Ripstream); /* Read persistant object */
virtual void write(Ropstream); /* Write persistant object */
PXFieldTypeDate(StreamableInit): /* Persistant object
constructor */
PXFieldTypeBase(streamableInit)
{
}
public:
PXFieldTypeDate(PPXField my_field); /* Constructor references
back to parent. */
~PXFieldTypeDate(void);
static PTStreamable build(); /* Build persistant object */
/* Get your DATE data
from record buffer */
int Get(void);
/* Put your double data in
the record buffer */
int Put(void);
};
// Description -------------------------------------------------------------
//
// This class spec's out getting and putting functions for DATES type
// data.
//
// End ---------------------------------------------------------------------
// Define inserters and extractors for persistant objects:
inline Ripstream operator >> (Ripstream is,RPXFieldTypeDate cl)
{return is >> (RTStreamable)cl;}
inline Ripstream operator >> (Ripstream is,RPPXFieldTypeDate cl)
{return is >> (RPvoid)cl;}
inline Ropstream operator << (Ropstream os,RPXFieldTypeDate cl)
{return os << (RTStreamable)cl;}
inline Ropstream operator << (Ropstream os,PPXFieldTypeDate cl)
{return os << (PTStreamable)cl;}
#endif // PXFIELD.HPP //